﻿/*
 * =====================================================================================
 *
 *       Filename:  GetHelper
 *
 *    Description:  获取一些系统或者应用程序信息的类库
 *
 *        Version:  1.0
 *        Created:  
 *       Revision:  none
 *       Compiler:  
 *
 *         Author:   imbedinlove
 *        Company:  
 *       EditTime:   2014年7月17日 09:28:54
 *
 * =====================================================================================

 */

using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Principal;
using System.Text;

namespace ImbedLibrary
{
    public class GetHelper
    {
        /// <summary>
        /// 获取本机IP
        /// </summary>
        /// <returns>本机IP</returns>
        public static String IP()
        {
            return IPAdd().ToString();
        }

        /// <summary>
        /// 获取本机IP
        /// </summary>
        /// <returns></returns>
        public static IPAddress IPAdd()
        {
            String hostName = Dns.GetHostName();
            IPHostEntry entry = Dns.GetHostByName(hostName);
            IPAddress ip = new IPAddress(entry.AddressList[0].Address);
            return ip;
 
        }

        /// <summary>
        /// 是否是管理员
        /// </summary>
        /// <returns></returns>
        public static bool IsAdministrator()
        {
            WindowsIdentity identity = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal = new WindowsPrincipal(identity);
            return principal.IsInRole(WindowsBuiltInRole.Administrator);
        }

        /// <summary>
        /// 获取应用程序执行路径
        /// </summary>
        /// <returns></returns>
        public static string WebPath()
        {
            return System.AppDomain.CurrentDomain.BaseDirectory;
        }
    }
}
